public class BinarySearchTest {
    public static void main(String[] args) {
        // Binary Search
        // Need a SORT process before BINARY SEARCH
        int[] arr = new int[]{-97, -64, -32, -3, 2, 34, 56, 66, 878};
        int dest = 66;
        int head = 0;   // Initial the head index
        int end = arr.length - 1; // Initial the end index
        boolean notFound = true;
        while(head < end){
            int middle = (head + end)  / 2;
            if(dest == arr[middle]){
                notFound = false;
                System.out.println("Dest: " + dest + "\tindex: " + middle);
                break;
            } else if (dest < arr[middle]) {
                end = middle - 1;
            } else {
                head = middle + 1;
            }
        }
        if(notFound){
            System.out.println("Not Found");
        }
    }
}
